#!/usr/bin/python

import sys

############NOTE#################
# Change this value if necessary
################################
N = 1511840

cat_hash = {}

for eachLine in sys.stdin:
    eachLine = eachLine.strip()
    if(eachLine.strip("\t")[0] == "*"):
        if(eachLine.strip("\t")[1] == "*"):
            continue

        category = eachLine.split("\t")[1]
        count = eachLine.split("\t")[2]
        
        print category+"\t*\t"+count

    else:
        eachLine = "\t".join(eachLine.split("\t")[:len(eachLine.split("\t"))-2])

        art_name = eachLine.split("\t")[0]
        categories = eachLine.split("\t")[1:]

        for eachCategory in categories:
            print eachCategory+"\t"+art_name
